package dk.dashboardFP.interactionElementFramwork.inputElement {
	import dk.dashboardFP.interactionElementFramwork.InteractionElement;
	import dk.dashboardFP.interactionElementFramwork.inputElementViews.InputElementViewEvent;
	import dk.dashboardFP.interactionElementFramwork.inputElementViews.AbstractInputElementView;

	/**
	 * @author jk
	 */
	public class AbstractInputElement extends InteractionElement {

		private var _bIsDefault : Boolean = true;

		public function AbstractInputElement(doIEV : AbstractInputElementView) {
			super(doIEV);
			
			_bOwnsKeyFocus = true;
			setupListeners();
		}

		private function setupListeners() : void {
			_doIEV.addEventListener(InputElementViewEvent.ENTER_DEFAULT, onEnterDefault, false, 0, true);
			_doIEV.addEventListener(InputElementViewEvent.LEAVE_DEFAULT, onLeaveDefault, false, 0, true);
		}

		private function onLeaveDefault(event : InputElementViewEvent) : void {
			_bIsDefault = false;
			dispatchEvent(new InputElementEvent(InputElementEvent.DEFAULT_VALUE_STATE_CHANGE));
		}

		private function onEnterDefault(event : InputElementViewEvent) : void {
			_bIsDefault = true;
			dispatchEvent(new InputElementEvent(InputElementEvent.DEFAULT_VALUE_STATE_CHANGE));
		}

		public function get bIsDefault() : Boolean {
			return _bIsDefault;
		}
	}
}
